﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;

namespace HPFCommon.Data.Ado
{
    /// <summary>
    /// 
    /// </summary>
    public class DPAHelper
    {
        public static bool IsEntity(Type type)
        {
            return type.GetCustomAttributes(typeof(TableAttribute),false) != null;
        }
        public static String GetTableName(Type type)
        {
            if(!IsEntity(type)) return "";

            TableAttribute table  = (TableAttribute)type.GetCustomAttributes(typeof(TableAttribute), false)[0];
            if (table.Name==null)
            {
                return type.Name;
            }
            else
            {
                return table.Name;
            }
        }
    }
}
